﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Redboil.Bfp.Core;
using System.ComponentModel.DataAnnotations;

namespace Redboil.Bfp.Model {
    public class TransportOrder : EntityBase {
        /// <summary>
        /// 发站
        /// </summary>
        [Required(ErrorMessage = "不能为空！")]
        [StringLength(30, ErrorMessage = "不能超过30个字符!")]
        public virtual string StartStation { get; set; }

        /// <summary>
        /// 到站（局）
        /// </summary>
        [StringLength(30, ErrorMessage = "不能超过30个字符!")]
        public virtual string Destionation { get; set; }

        /// <summary>
        /// 到站所属省（市）自治区
        /// </summary>
        [StringLength(30, ErrorMessage = "不能超过30个字符!")]
        public virtual string ProvinceOfDestionation { get; set; }

        /// <summary>
        /// 发货地点
        /// </summary>
        [StringLength(30, ErrorMessage = "不能超过30个字符!")]
        public virtual string StartStationLocation { get; set; }

        /// <summary>
        /// 交货地点
        /// </summary>
        [StringLength(30, ErrorMessage = "不能超过30个字符!")]
        public virtual string DeliveryLocation { get; set; }

        /// <summary>
        /// 托运人名称
        /// </summary>
        [Required(ErrorMessage = "不能为空！")]
        [StringLength(50, ErrorMessage = "不能超过50个字符!")]
        public virtual string CommissionedorName { get; set; }

        /// <summary>
        /// 托运人电话
        /// </summary>
        [StringLength(50, ErrorMessage = "不能超过50个字符!")]
        public virtual string CommissionedorTelephone { get; set; }

        /// <summary>
        /// 托运人地址
        /// </summary>
        [StringLength(100, ErrorMessage = "不能超过100个字符!")]
        public virtual string CommissionedorAddress { get; set; }

        /// <summary>
        /// 托运人邮编
        /// </summary>
        [StringLength(6, ErrorMessage = "不能超过6个字符!")]
        public virtual string CommissionedorPostNumber { get; set; }

        /// <summary>
        /// 托运人Email
        /// </summary>
        [StringLength(100, ErrorMessage = "不能超过100个字符!")]
        public virtual string CommissionedorEmail { get; set; }
        /// <summary>
        /// 收货人名称
        /// </summary>
        [StringLength(50, ErrorMessage = "不能超过50个字符!")]
        public virtual string ReceiverName { get; set; }

        /// <summary>
        /// 收货人电话
        /// </summary>
        [StringLength(50, ErrorMessage = "不能超过50个字符!")]
        public virtual string ReceiverTelephone { get; set; }

        /// <summary>
        /// 收货人地址
        /// </summary>
        [StringLength(100, ErrorMessage = "不能超过100个字符!")]
        public virtual string ReceiverAddress { get; set; }

        /// <summary>
        /// 收货人邮编
        /// </summary>
        [StringLength(6, ErrorMessage = "不能超过6个字符!")]
        public virtual string ReceiverPostNumber { get; set; }

        /// <summary>
        /// 收货人Email
        /// </summary>
        [StringLength(100, ErrorMessage = "不能超过100个字符!")]
        public virtual string ReceiverEmail { get; set; }

        /// <summary>
        /// 托运人记载事项
        /// </summary>
        [StringLength(1000, ErrorMessage = "不能超过1000个字符!")]
        public virtual string CommissionedorRemark { get; set; }

        /// <summary>
        /// 承运人记载事项
        /// </summary>
        [StringLength(1000, ErrorMessage = "不能超过1000个字符!")]
        public virtual string TransportorRemark { get; set; }

        //public TransportStatus Status {
        //    get {
        //        if(Items == null || Items.Count < 1) {
        //            return TransportStatus.Init;
        //        }
        //        else {
        //            foreach(TranportOrderItem item in Items) {
        //                if(item.Status == TransportStatus.Init) {
        //                    return TransportStatus.Init;
        //                }
        //            }
        //            return TransportStatus.Done;
        //        }
        //    }
        //}

        /// <summary>
        /// 创建人
        /// </summary>
        public virtual User Creator { get; set; }

        /// <summary>
        /// 总运费
        /// </summary>
        //public virtual decimal TotalTransportFee {
        //    get {
        //        decimal total = 0;
        //        if(Items == null) {
        //            return total;
        //        }
        //        foreach(TranportOrderItem item in Items) {
        //            if(item == null) { continue; }
        //            total += item.TransportFee;
        //        }
        //        return total;
        //    }
        //}

        /// <summary>
        /// 工单总数
        /// </summary>
        //public virtual int TranportOrderItemCount {
        //    get {
        //        if(Items == null) {
        //            return 0;
        //        }
        //        return Items.Count;
        //    }
        //}

        /// <summary>
        /// 运输单项目
        /// </summary>
        //spublic virtual IList<TranportOrderItem> Items { get; set; }
    }
}
